package com.ruoyi.wq.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.Condition;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.wq.mapper.WqTuanMapper;
import com.ruoyi.wq.domain.WqTuan;
import com.ruoyi.wq.domain.vo.WqTuanVO;
import com.ruoyi.wq.service.IWqTuanService;

/**
 * 拼团Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-08-28
 */
@Service
public class WqTuanServiceImpl extends ServiceImpl<WqTuanMapper, WqTuan> implements IWqTuanService {

    @Autowired
    private WqTuanMapper wqTuanMapper;

    /**
     * 查询拼团
     * 
     * @param id 拼团主键
     * @return 拼团
     */
    @Override
    public WqTuan selectWqTuanById(String id)
    {
        return wqTuanMapper.selectWqTuanById(id);
    }

    /**
     * 查询拼团列表
     * 
     * @param wqTuan 拼团
     * @return 拼团
     */
    @Override
    public List<WqTuan> selectWqTuanList(WqTuan wqTuan)
    {
        return wqTuanMapper.selectWqTuanList(wqTuan);
    }

    /**
     * 新增拼团
     * 
     * @param wqTuan 拼团
     * @return 结果
     */
    @Override
    public int insertWqTuan(WqTuan wqTuan)
    {
        wqTuan.setCreateTime(DateUtils.getNowDate());
        return wqTuanMapper.insertWqTuan(wqTuan);
    }

    /**
     * 修改拼团
     * 
     * @param wqTuan 拼团
     * @return 结果
     */
    @Override
    public int updateWqTuan(WqTuan wqTuan)
    {
        wqTuan.setUpdateTime(DateUtils.getNowDate());
        return wqTuanMapper.updateWqTuan(wqTuan);
    }

    /**
     * 批量删除拼团
     * 
     * @param ids 需要删除的拼团主键
     * @return 结果
     */
    @Override
    public int deleteWqTuanByIds(String[] ids)
    {
        return wqTuanMapper.deleteWqTuanByIds(ids);
    }

    /**
     * 删除拼团信息
     * 
     * @param id 拼团主键
     * @return 结果
     */
    @Override
    public int deleteWqTuanById(String id)
    {
        return wqTuanMapper.deleteWqTuanById(id);
    }

	@Override
	public TableDataInfo getPageList(WqTuan wqTuan) {
		IPage<WqTuanVO> page = baseMapper.selectPageList(Condition.getPage(wqTuan), wqTuan);
		return Condition.getTableDataInfo(page.getRecords(), page.getTotal());
	}
}
